package wql.aaa.controller;

import com.aaa.entity.TbLink;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wql.aaa.service.TbLinkService;
import wql.aaa.vo.BottomFormData;
import wql.aaa.vo.LinkFormData;

/**
 * @author wql
 * @version 1.0
 * @date 2023/2/28 16:50
 */
@RestController
@RequestMapping("home/link")
public class TbLinkController {

    @Autowired
    private TbLinkService tbLinkService;

    @PostMapping("/getAllLink/{currentPage}/{pageSize}")
    public Result selectAll(@PathVariable Integer currentPage,@PathVariable Integer pageSize, @RequestBody LinkFormData linkFormData){
        return tbLinkService.queryAll(currentPage,pageSize,linkFormData);
    }

    @PostMapping("/addLink")
    public Result add(@RequestBody TbLink tbLink){
        return  tbLinkService.add(tbLink);

    }

    @PostMapping("/changeStatus/{linkId}/{isDisable}")
    public  Result change(@PathVariable String linkId ,@PathVariable Integer isDisable){
        return tbLinkService.change(linkId,isDisable);
    }

    @PostMapping("/deleteLink/{linkId}")
    public Result delete(@PathVariable String linkId){
        return  tbLinkService.deleteByLinkId(linkId);
    }

    @PostMapping("/editLink")
    public Result edit(@RequestBody TbLink tbLink){
        return  tbLinkService.updateLink(tbLink);
    }

}
